package com.cloudsigns.factorymanager2.media_system.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.project.customview.GeneralPurposePoupWindow;
import com.cloudsigns.factorymanager2.project.myinerface.ItemClickListener;

public class MediaSystemOfficeFragment extends Fragment implements OnClickListener, ItemClickListener {
    private TextView edit_query_type;
    private View v_query_type;
    private ImageView img_query_type;
    private RelativeLayout rl_query;
    private GeneralPurposePoupWindow generalPurposePoupWindow;
    private String types[] = {"工程施工", "广告上刊", "维修", "维护保养"};

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_media_system_office, null);
        edit_query_type = view.findViewById(R.id.edit_query_type);
        v_query_type = view.findViewById(R.id.v_query_type);
        img_query_type = view.findViewById(R.id.img_query_type);
        rl_query = view.findViewById(R.id.rl_query);

        img_query_type.setOnClickListener(this);
        rl_query.setOnClickListener(this);
        return view;
    }

    // 查询类型
    private void showSearchTypesWindow(View anchor) {
        generalPurposePoupWindow = new GeneralPurposePoupWindow(getActivity(), types);
        generalPurposePoupWindow.setItemClick(this);
        generalPurposePoupWindow.showPopupWindow(anchor);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            // 查询类型
            case R.id.img_query_type:
                showSearchTypesWindow(v_query_type);
                break;
            // 保存
            case R.id.rl_query:
                break;
        }
    }

    @Override
    public void itemClick(View view, int position) {
        edit_query_type.setText(types[position]);
    }
}
